package com.wjjm.spoonselling.service.impl;

import com.wjjm.spoonselling.dao.CommodityDao;
import com.wjjm.spoonselling.pojo.Commodity;
import com.wjjm.spoonselling.service.CommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommodityServiceImpl implements CommodityService {

    @Autowired
    private CommodityDao commodityDao;

    @Override
    public List<Commodity> selectAll() {
        List<Commodity> commodities = commodityDao.selectAll();
        return commodities;
    }

    @Override
    public Commodity selectById(int commodityId) {
        Commodity commodity = commodityDao.selectById(commodityId);
        return commodity;
    }

    @Override
    public List<Commodity> selectByName(String name) {
        List<Commodity> commodities = commodityDao.selectByName(name);
        return commodities;
    }

    @Override
    public boolean update(Commodity commodity) {
        int i = commodityDao.update(commodity);
        return i>0;
    }

    @Override
    public boolean deleteById(int commodityId) {
        int i = commodityDao.deleteById(commodityId);
        return i>0;
    }

    @Override
    public int insert(Commodity commodity) {
        int i = commodityDao.insert(commodity);
        return i;
    }
}
